package com.yunxi.service.dubboService.impl.sys;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.FileUtils;

import java.io.File;

public class JsonRead {

    public static void main(String args[]) {
        //String path = getClass().getClassLoader().getResource("area.json").toString();
        //path = path.replace("\\", "/");
        //if (path.contains(":")) {
            //path = path.substring(6);// 1
          //  path = path.replace("file:/", "");// 2
        //}
        JSONArray jsonArray = null;
        try {
            String input = FileUtils.readFileToString(new File("D://1111.json"), "UTF-8");
            input=input+"\"}]}";
            JSONObject jsonObject = JSONObject.parseObject(input);
            if (jsonObject != null) {
                jsonArray = jsonObject.getJSONArray("Data");
                System.out.println(jsonArray.size());

                for (int i=0;i<jsonArray.size();i++)
                {
                    JSONObject o = (JSONObject)jsonArray.get(i);
                    System.out.println(o);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            jsonArray = null;
        }
    }
}
